package cn.xiaoxige.plugin.entity

import org.gradle.api.NamedDomainObjectContainer

/*
 * Copyright (C) 2020 Baidu, Inc. All Rights Reserved.
 */

class Clazz {
    def schoolName
    def name

    NamedDomainObjectContainer<Person> persons

    public Clazz(NamedDomainObjectContainer<Person> persons) {
        this.persons = persons
    }

    def persons(Closure closure) {
        persons.configure(closure)
    }

    @Override
    String toString() {
        def personsInfo = ''
        persons.forEach { person ->
            personsInfo += person.toString() + "\n"
        }
        return "学校: $schoolName. \n 班级: $name.\n班级成员如下：\n $personsInfo"
    }
}